package com.example.blogserver.controller;

import com.example.blogserver.pojo.User;
import com.example.blogserver.service.RegService;
import com.example.blogserver.a_utils.ResponseBodyMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@SuppressWarnings({"all"})
@RestController
@RequestMapping("/register")
public class RegController {
    @Autowired
    private RegService regService;

    /**
     * 获取Redis操作对象
     */
    @Autowired
    private RedisTemplate redisTemplate;

    /**
     * 实现用户注册发送验证码
     */
    @RequestMapping("/sendEmailCode")
    public ResponseBodyMessage<Boolean> sendEmailCode(HttpServletRequest request, @RequestParam String emailId){
        return regService.sendEmailCode(request,emailId);
    }

    /**
     * 注册账号
     */
    @RequestMapping("/Registration")
    public ResponseBodyMessage<User> Reg(HttpServletRequest request,
                                         @RequestParam String emailId,
                                         @RequestParam String emailCode,
                                         @RequestParam String passworda,
                                         @RequestParam String passwordb){
        return regService.Reg(request,emailId,emailCode,passworda,passwordb);
    }
}
